﻿// Decompiled with JetBrains decompiler
// Type: Bannerlord.ModuleManager.ApplicationVersionRange
// Assembly: MCMv5, Version=5.10.2.0, Culture=neutral, PublicKeyToken=null
// MVID: 7AB326B9-B2B4-41C2-9177-68E944071101
// Assembly location: D:\steam\steamapps\workshop\content\261550\2859238197\bin\Win64_Shipping_Client\MCMv5.dll

using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Text;

#nullable enable
namespace Bannerlord.ModuleManager
{
  internal record ApplicationVersionRange()
  {
    public static ApplicationVersionRange Empty => new ApplicationVersionRange();

    public ApplicationVersion Min { get; set; } = ApplicationVersion.Empty;

    public ApplicationVersion Max { get; set; } = ApplicationVersion.Empty;

    public ApplicationVersionRange(ApplicationVersion min, ApplicationVersion max)
    {
      this.Max = max;
      this.Min = min;
    }

    public bool IsSame(ApplicationVersionRange? other)
    {
      return this.Min.IsSame(other?.Min) && this.Max.IsSame(other?.Max);
    }

    public bool IsSameWithChangeSet(ApplicationVersionRange? other)
    {
      return this.Min.IsSameWithChangeSet(other?.Min) && this.Max.IsSameWithChangeSet(other?.Max);
    }

    public override string ToString()
    {
      return string.Format("{0} - {1}", (object) this.Min, (object) this.Max);
    }

    public static bool TryParse(
      string versionRangeAsString,
      out ApplicationVersionRange versionRange)
    {
      versionRange = ApplicationVersionRange.Empty;
      if (string.IsNullOrWhiteSpace(versionRangeAsString))
        return false;
      versionRangeAsString = versionRangeAsString.Replace(" ", string.Empty);
      int length = versionRangeAsString.IndexOf('-');
      if (length < 0)
        return false;
      string versionAsString1 = versionRangeAsString.Substring(0, length);
      string versionAsString2 = versionRangeAsString.Substring(length + 1, versionRangeAsString.Length - 1 - length);
      ApplicationVersion version1;
      ApplicationVersion version2;
      if (!ApplicationVersion.TryParse(versionAsString1, out version1, true) || !ApplicationVersion.TryParse(versionAsString2, out version2, false))
        return false;
      versionRange = new ApplicationVersionRange()
      {
        Min = version1,
        Max = version2
      };
      return true;
    }

    [CompilerGenerated]
    protected virtual bool PrintMembers(StringBuilder builder)
    {
      RuntimeHelpers.EnsureSufficientExecutionStack();
      builder.Append("Min = ");
      builder.Append((object) this.Min);
      builder.Append(", Max = ");
      builder.Append((object) this.Max);
      return true;
    }

    [CompilerGenerated]
    public override int GetHashCode()
    {
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      return (EqualityComparer<Type>.Default.GetHashCode(this.EqualityContract) * -1521134295 + EqualityComparer<ApplicationVersion>.Default.GetHashCode(this.\u003CMin\u003Ek__BackingField)) * -1521134295 + EqualityComparer<ApplicationVersion>.Default.GetHashCode(this.\u003CMax\u003Ek__BackingField);
    }

    [CompilerGenerated]
    public virtual bool Equals(ApplicationVersionRange? other)
    {
      if ((object) this == (object) other)
        return true;
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      return (object) other != null && this.EqualityContract == other.EqualityContract && EqualityComparer<ApplicationVersion>.Default.Equals(this.\u003CMin\u003Ek__BackingField, other.\u003CMin\u003Ek__BackingField) && EqualityComparer<ApplicationVersion>.Default.Equals(this.\u003CMax\u003Ek__BackingField, other.\u003CMax\u003Ek__BackingField);
    }

    [CompilerGenerated]
    protected ApplicationVersionRange(ApplicationVersionRange original)
    {
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      this.\u003CMin\u003Ek__BackingField = original.\u003CMin\u003Ek__BackingField;
      // ISSUE: reference to a compiler-generated field
      // ISSUE: reference to a compiler-generated field
      this.\u003CMax\u003Ek__BackingField = original.\u003CMax\u003Ek__BackingField;
    }
  }
}
